package com.yuanzong.wuliu.common.utils.workbook.demo;

import com.yuanzong.wuliu.common.utils.workbook.ExcelUtil;
import com.yuanzong.wuliu.common.utils.workbook.HeadDetails;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 *@author: zhao yue yue
 *@create: 2022-07-21 13:58
 */
public class WorkBookDemo {


    public static void initializeExcel(Map<String,Object> map, HttpServletResponse response){
        List<Object> list=(List<Object>)map.get("list");
        String sheetName=map.get("name").toString();
        HeadDetails headDetails = new HeadDetails()
                .add("name","名称")
                .add("age","年龄")
                .add("sex","性别");
        ExcelUtil workbookUtil = new ExcelUtil(sheetName);
        workbookUtil.initWorkbook().initSheet(sheetName,null)
                .initSheetHead(headDetails,sheetName,null,null)
                .setSheetData(headDetails,list,null).builderResponseEntity();
        ExcelUtil.downloadExcel(workbookUtil.hssfWorkbook,response,"ceshi.xls");

    }




}
